import { createRecord, findRecordList, findRecordOne ,updateRecord, deleteRecord,findMyRecordList,findRecordDeclareList,findRecordById,recordTopIndex,selectMyApplyRecord} from '@/api/recordManager'

const recordManager = {
    actions: {
        // 创建
        CreateRecord({ commit }, data) {
            return new Promise((resolve, reject) => {
                createRecord(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        // 修改
        UpdateRecord({ commit }, data) {
            return new Promise((resolve, reject) => {
                updateRecord(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        // 删除
        DeleteRecord({ commit }, data) {
            return new Promise((resolve, reject) => {
                deleteRecord(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //查询list
        FindRecordList({ commit }, data) {
            return new Promise((resolve, reject) => {
                findRecordList(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //单个查询
        FindRecordOne({ commit }, data) {
            return new Promise((resolve, reject) => {
                findRecordOne(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //我的列表查询
        FindMyRecordList({ commit }, data) {
            return new Promise((resolve, reject) => {
                findMyRecordList(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //待审核的申报查询
        FindRecordDeclareList({ commit }, data){
            return new Promise((resolve, reject) => {
                findRecordDeclareList(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        //查询单个档案
        FindRecordById({commit},data){
            return new Promise((resolve, reject) => {
                findRecordById(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        // 置顶档案到首页
        RecordTopIndex({commit},data){
            return new Promise((resolve,reject) => {
                recordTopIndex(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        // 查询我的最新申报档案
        SelectMyApplyRecord({commit},data){
            return new Promise((resolve,reject) => {
                selectMyApplyRecord(data).then(response => {
                    resolve(response)
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default recordManager
